package com.zzptc.easyshop.control;

import com.zzptc.easyshop.dao.GoodProDaoImp;
import com.zzptc.easyshop.dao.IDAO;
import com.zzptc.easyshop.vo.Good;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "ProductViewServlet")
public class ProductViewServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //System.out.println("商品详情页面来了！！");
        //1、获取商品ID。2、取数据。3、在两个页面之间传递数据。4、转到显示商品详情的页面。
        String id=request.getParameter("id");
        int idd=Integer.parseInt(id);
        String s=4+"";

        IDAO idao=new GoodProDaoImp();
        Good good=((GoodProDaoImp) idao).getGoodByID(idd);


        request.setAttribute("goodinfo",good);

        request.getRequestDispatcher("product-view.jsp").forward(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            doPost(request,response);
    }
}
